package org.senseframework.support.example.mongo;


import com.sun.org.apache.xpath.internal.operations.String;
import org.senseframework.support.orm.mongodb.Mongo;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;

import java.util.List;

/**
 * Created by lanjian on 30/08/2017.
 */
public class MongoMain {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext c = new ClassPathXmlApplicationContext("spring_example_mongo.xml");
        MongoTemplate source = c.getBean(MongoTemplate.class);
//        List<Ring> rings=Mongo.build(source).eq("id",1).remove();
//        for (int i = 0; i <= 120; i++) {
//            MongoTest a = new MongoTest(i + "a", i + "b");
//            Mongo.build(source).insert(a);
//            System.out.println(a);
//        }
//        List<MongoTest> mongoTestList = Mongo.build(source).all(MongoTest.class);
//        System.out.println("1" + mongoTestList);
//        List<MongoTest> mongoTestLis1t = Mongo.build(source).eq("a", "1a").list(MongoTest.class);
//        System.out.println("2" + mongoTestLis1t);
//        MongoTest one = Mongo.build(source).eq("a", "117a").one(MongoTest.class);
//        System.out.println("3" + one);
//        MongoTest one1 = Mongo.build(source).load("59a655c6b7f480a5d8fd3717", MongoTest.class);
//        System.out.println("4" + one1);
//        String sql="select c.id as id ,c.a as a,a.c as c from c as c  left join （select * FROM a left join b on a.id=b.id） as ab on ad.id=c.id ";
//        String baseCount="select count(1) ";
//        String jsql=sql.toLowerCase();
//        int formIndex=jsql.indexOf("from");
//        StringBuffer stringBuffer=new StringBuffer(baseCount);
//        stringBuffer.append(sql.substring(formIndex));
//        System.out.println(stringBuffer.toString());
    }
}
